package gitee.derumin.lifeissohard.generate.advancements;

import gitee.derumin.lifeissohard.criteria.NutritionEffectsCriterion;
import gitee.derumin.lifeissohard.item.LishItems;
import gitee.derumin.lifeissohard.tools.LishIdentifiers;
import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.AdvancementFrame;
import net.minecraft.advancement.AdvancementRewards;
import net.minecraft.advancement.criterion.ConsumeItemCriterion;
import net.minecraft.item.Items;
import net.minecraft.potion.Potions;
import net.minecraft.predicate.item.ItemPredicate;
import net.minecraft.text.Text;

import java.util.function.Consumer;

public class LifeIsSoHard implements Consumer<Consumer<Advancement>> {
    @Override
    public void accept(Consumer<Advancement> advancementConsumer) {
        // this is root
        Advancement rootAdvancement = Advancement.Builder.create()
                .display(
                        Items.DAMAGED_ANVIL,
                        Text.translatable("advancements.lifeissohard.all_the_beginning.title"),
                        Text.translatable("advancements.lifeissohard.all_the_beginning.description"),
                        LishIdentifiers.Textures.Gui.ADVENTURE_BACKGROUND,
                        AdvancementFrame.TASK,
                        true,
                        false,
                        false
                )
                .criterion("fell_hungry", (new NutritionEffectsCriterion.ConditionBuilder())
                        .isHungry(true)
                        .build())
                .build(advancementConsumer,"lifeissohard/root");
        //this is dyspepsia
        Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        Items.CARROT,
                        Text.translatable("advancements.lifeissohard.dyspepsia.title"),
                        Text.translatable("advancements.lifeissohard.dyspepsia.description"),
                        null,
                        AdvancementFrame.TASK,
                        true,
                        true,
                        true
                ).criterion("dyspepsia",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isDyspepsia(true)
                        .build())
                .build(advancementConsumer,"lifeissohard/dyspepsia");
        //this is feel thirsty
        Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        Items.WATER_BUCKET,
                        Text.translatable("advancements.lifeissohard.feel_thirsty.title"),
                        Text.translatable("advancements.lifeissohard.feel_thirsty.description"),
                        null,
                        AdvancementFrame.TASK,
                        true,
                        true,
                        false
                )
                .criterion("fell_thirsty",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isThirsty(true)
                        .build())
                .rewards(AdvancementRewards.Builder.loot(LishIdentifiers.LootTables.FIRST_THIRSTY))
                .build(advancementConsumer,"lifeissohard/feel_thirsty");
        //this is suggest_test
        String[][] requirements1 = new String[1][5];
        requirements1[0] = new String[]{"lack_va", "lack_vb", "lack_vc", "lack_iodine", "iodine_excess"};
        Advancement suggestTest = Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        LishItems.BLOOD_TESTER_USED,
                        Text.translatable("advancements.lifeissohard.suggest_test.title"),
                        Text.translatable("advancements.lifeissohard.suggest_test.description"),
                        null,
                        AdvancementFrame.TASK,
                        true,
                        true,
                        false
                )
                .criterion("lack_va",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVA(true)
                        .build())
                .criterion("lack_vb",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVB(true)
                        .build())
                .criterion("lack_vc",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVC(true)
                        .build())
                .criterion("lack_iodine",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInIodine(true)
                        .build())
                .criterion("iodine_excess",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isIodineExcess(true)
                        .build())
                .requirements(requirements1)
                .rewards(AdvancementRewards.Builder.loot(LishIdentifiers.LootTables.BLOOD_TESTER))
                .build(advancementConsumer,"lifeissohard/suggest_test");
        //this is scurvy
        Advancement.Builder.create()
                .parent(suggestTest)
                .display(
                        Items.SWEET_BERRIES,
                        Text.translatable("advancements.lifeissohard.scurvy.title"),
                        Text.translatable("advancements.lifeissohard.scurvy.description"),
                        null,
                        AdvancementFrame.CHALLENGE,
                        true,
                        true,
                        true
                )
                .criterion("lack_vc",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVC(true)
                        .build())
                .rewards(AdvancementRewards.Builder.experience(100))
                .build(advancementConsumer,"lifeissohard/scurvy");
        //this is feel bad
        String[][] requirements2 = new String[1][38];
        requirements2[0] = new String[]{
                "drink_potion1",
                "drink_potion2",
                "drink_potion3",
                "drink_potion4",
                "drink_potion5",
                "drink_potion6",
                "drink_potion7",
                "drink_potion8",
                "drink_potion9",
                "drink_potion10",
                "drink_potion11",
                "drink_potion12",
                "drink_potion13",
                "drink_potion14",
                "drink_potion15",
                "drink_potion16",
                "drink_potion17",
                "drink_potion18",
                "drink_potion19",
                "drink_potion20",
                "drink_potion21",
                "drink_potion22",
                "drink_potion23",
                "drink_potion24",
                "drink_potion25",
                "drink_potion26",
                "drink_potion27",
                "drink_potion28",
                "drink_potion29",
                "drink_potion30",
                "drink_potion31",
                "drink_potion32",
                "drink_potion33",
                "drink_potion34",
                "drink_potion35",
                "drink_potion36",
                "drink_potion37",
                "drink_potion38"
        };
        Advancement feelBad = Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        Items.POTION,
                        Text.translatable("advancements.lifeissohard.feel_bad.title"),
                        Text.translatable("advancements.lifeissohard.feel_bad.description"),
                        null,
                        AdvancementFrame.TASK,
                        true,
                        true,
                        true
                )
                .criterion("drink_potion1", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.AWKWARD)
                                .build()))
                .criterion("drink_potion2", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.NIGHT_VISION)
                                .build()))
                .criterion("drink_potion3", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_NIGHT_VISION)
                                .build()))
                .criterion("drink_potion4", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.INVISIBILITY)
                                .build()))
                .criterion("drink_potion5", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_INVISIBILITY)
                                .build()))
                .criterion("drink_potion6", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LEAPING)
                                .build()))
                .criterion("drink_potion7", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_LEAPING)
                                .build()))
                .criterion("drink_potion8", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_LEAPING)
                                .build()))
                .criterion("drink_potion9", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.FIRE_RESISTANCE)
                                .build()))
                .criterion("drink_potion10", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_FIRE_RESISTANCE)
                                .build()))
                .criterion("drink_potion11", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.SWIFTNESS)
                                .build()))
                .criterion("drink_potion12", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_SWIFTNESS)
                                .build()))
                .criterion("drink_potion13", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_SWIFTNESS)
                                .build()))
                .criterion("drink_potion14", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.SLOWNESS)
                                .build()))
                .criterion("drink_potion15", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_SLOWNESS)
                                .build()))
                .criterion("drink_potion16", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.WATER_BREATHING)
                                .build()))
                .criterion("drink_potion17", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_WATER_BREATHING)
                                .build()))
                .criterion("drink_potion18", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.HEALING)
                                .build()))
                .criterion("drink_potion19", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_HEALING)
                                .build()))
                .criterion("drink_potion20", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.HARMING)
                                .build()))
                .criterion("drink_potion21", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_HARMING)
                                .build()))
                .criterion("drink_potion22", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.POISON)
                                .build()))
                .criterion("drink_potion23", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.POISON)
                                .build()))
                .criterion("drink_potion24", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_POISON)
                                .build()))
                .criterion("drink_potion25", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.REGENERATION)
                                .build()))
                .criterion("drink_potion26", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_REGENERATION)
                                .build()))
                .criterion("drink_potion27", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_REGENERATION)
                                .build()))
                .criterion("drink_potion28", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRENGTH)
                                .build()))
                .criterion("drink_potion29", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_STRENGTH)
                                .build()))
                .criterion("drink_potion30", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_STRENGTH)
                                .build()))
                .criterion("drink_potion31", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.WEAKNESS)
                                .build()))
                .criterion("drink_potion32", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_WEAKNESS)
                                .build()))
                .criterion("drink_potion33", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LUCK)
                                .build()))
                .criterion("drink_potion34", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.SLOW_FALLING)
                                .build()))
                .criterion("drink_potion35", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_SLOW_FALLING)
                                .build()))
                .criterion("drink_potion36", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.TURTLE_MASTER)
                                .build()))
                .criterion("drink_potion37", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.LONG_TURTLE_MASTER)
                                .build()))
                .criterion("drink_potion38", ConsumeItemCriterion.Conditions
                        .predicate(ItemPredicate.Builder.create()
                                .potion(Potions.STRONG_TURTLE_MASTER)
                                .build()))
                .requirements(requirements2)
                .rewards(AdvancementRewards.Builder.loot(LishIdentifiers.LootTables.BLOOD_TESTER))
                .build(advancementConsumer,"lifeissohard/feel_bad");
        //this is poisoned by heavy metal
        Advancement.Builder.create()
                .parent(feelBad)
                .display(
                        Items.MILK_BUCKET,
                        Text.translatable("advancements.lifeissohard.poisoned_by_heavy_metal.title"),
                        Text.translatable("advancements.lifeissohard.poisoned_by_heavy_metal.description"),
                        null,
                        AdvancementFrame.CHALLENGE,
                        true,
                        true,
                        true
                )
                .criterion("poisoned_by_heavy_metal",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isPoisonedByHeavyMetal(true)
                        .build())
                .rewards(AdvancementRewards.Builder.loot(LishIdentifiers.LootTables.BLOOD_TESTER))
                .build(advancementConsumer,"lifeissohard/poisoned_by_heavy_metal");
        //this is die_from_gluttony
        Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        Items.SKELETON_SKULL,
                        Text.translatable("advancements.lifeissohard.die_from_gluttony.title"),
                        Text.translatable("advancements.lifeissohard.die_from_gluttony.description"),
                        null,
                        AdvancementFrame.CHALLENGE,
                        true,
                        true,
                        true
                )
                .criterion("gluttony",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromGluttony(true)
                        .build())
                .build(advancementConsumer,"lifeissohard/die_from_gluttony");
        //this is die from starve
        Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        Items.SKELETON_SKULL,
                        Text.translatable("advancements.lifeissohard.die_from_starved.title"),
                        Text.translatable("advancements.lifeissohard.die_from_starved.description"),
                        null,
                        AdvancementFrame.CHALLENGE,
                        true,
                        true,
                        true
                )
                .criterion("starved",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromStarve(true)
                        .build())
                .rewards(AdvancementRewards.Builder.loot(LishIdentifiers.LootTables.IMAGED_CAKE))
                .build(advancementConsumer,"lifeissohard/die_from_starve");
        //this is all_nutrition_effects
        Advancement.Builder.create()
                .parent(rootAdvancement)
                .display(
                        Items.PLAYER_HEAD,
                        Text.translatable("advancements.lifeissohard.all_nutrition_effects.title"),
                        Text.translatable("advancements.lifeissohard.all_nutrition_effects.description"),
                        null,
                        AdvancementFrame.CHALLENGE,
                        true,
                        true,
                        true
                )
                .criterion("weak",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isWeak(true)
                        .build())
                .criterion("hungry",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isHungry(true)
                        .build())
                .criterion("starved",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isStarved(true)
                        .build())
                .criterion("full",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isFull(true)
                        .build())
                .criterion("stomachEmpty",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isEmptyStomach(true)
                        .build())
                .criterion("thirsty",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isThirsty(true)
                        .build())
                .criterion("waterIntoxicated",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isWaterIntoxicated(true)
                        .build())
                .criterion("poisonedByHeavyMetal",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isPoisonedByHeavyMetal(true)
                        .build())
                .criterion("exhausted",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isExhausted(true)
                        .build())
                .criterion("dyspepsia",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isDyspepsia(true)
                        .build())
                .criterion("lack_in_va",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVA(true)
                        .build())
                .criterion("lack_in_vb",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVB(true)
                        .build())
                .criterion("lack_in_vc",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInVC(true)
                        .build())
                .criterion("lack_in_iodine",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInIodine(true)
                        .build())
                .criterion("iodine_excess",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isIodineExcess(true)
                        .build())
                .criterion("lack_in_strength",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isLackInStrength(true)
                        .build())
                .criterion("powerful",(new NutritionEffectsCriterion.ConditionBuilder())
                        .isPowerful(true)
                        .build())
                .criterion("cannot_regenerate",(new NutritionEffectsCriterion.ConditionBuilder())
                        .cannotRegenerate(true)
                        .build())
                .criterion("die_from_thirsty",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromThirsty(true)
                        .build())
                .criterion("die_from_water_intoxicated",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromWaterIntoxication(true)
                        .build())
                .criterion("die_from_stomach_rupture",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromStomachRupture(true)
                        .build())
                .criterion("die_from_gluttony",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromGluttony(true)
                        .build())
                .criterion("die_from_hypoglycemia",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromHypoglycemia(true)
                        .build())
                .criterion("die_from_hypoglycemia_exhausted",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromHypoglycemiaExhausted(true)
                        .build())
                .criterion("die_from_starve",(new NutritionEffectsCriterion.ConditionBuilder())
                        .dieFromStarve(true)
                        .build())
                .rewards(AdvancementRewards.Builder.experience(1000))
                .build(advancementConsumer,"lifeissohard/all_nutrition_effects");
    }
}
